﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rappelz.GameServer.Network;
using Rappelz.GameServer.Network.GameClient;
using Rappelz.GameServer.Database;

namespace Rappelz.GameServer
{
    public class Summon : Creature
    {
// Enum           :   <unnamed-tag>, Type: int
// Data           :     constant 0x46, Constant, Type: int, SUMMON_SPAWN_LENGTH
// Data           :     constant 0x18, Constant, Type: int, SUMMON_SPAWN_MIN_LENGTH
// Function       :   public static void StructSummon::BindProperty()
        public static Summon AllocSummon(Player player, uint code)
        {
            Summon res = new Summon(0,code);
            res.m_master = player;
            res.CalculateStat();
            res.m_nHP = res.m_nMaxHP;
            res.m_fMP = res.m_nMaxMP;
            res.m_nLevel = 1;
            res.m_nMaxReachedLevel = 1;
            res.m_fCM = 0.0f;
            res.m_fEXPMod = 1.0f;
            res.m_fJPMod = 1.0f;
            if(res.m_ContentInfo.is_riding_only == 1)
                res.SetSkill(-4, 11001, 1, 0);

            return res;
        }
// Function       :   public static void StructSummon::FreeSummon(struct StructSummon *)
// Function       :   public bool StructSummon::IsDeleteable()
// Function       :   public bool StructSummon::IsEnemy(struct StructCreature *, bool)
// Function       :   public bool StructSummon::IsSkillCastable()
// Function       :   public bool StructSummon::IsMagicCastable()
// Function       :   public bool IsRidable()

        public static void CalculateInitialJP(Item card, Summon ps)
        {
            switch (card.m_Instance.nEnhance)
            {
                case 1:
                    if(ps != null)
                        ps.m_nTotalJobPoint = 10;
                    card.m_Instance.nDurability = 15;
                    break;
                case 2:
                    if (ps != null)
                        ps.m_nTotalJobPoint = 19;
                    card.m_Instance.nDurability = 10;
                    break;
                case 3:
                    if (ps != null)
                        ps.m_nTotalJobPoint = 28;
                    card.m_Instance.nDurability = 6;
                    break;
                case 4:
                    if (ps != null)
                        ps.m_nTotalJobPoint = 37;
                    card.m_Instance.nDurability = 5;
                    break;
                case 5:
                    if (ps != null)
                        ps.m_nTotalJobPoint = 46;
                    card.m_Instance.nDurability = 3;
                    break;
            }
            if(ps != null)
                ps.m_nJobPoint = ps.m_nTotalJobPoint;
        }

        public bool SetSummonInfo(uint idx)
        {
            this.m_ContentInfo = GameContent.GetSummonInfo((int)idx);
            
            this.m_nJob = (int)idx;
            this.m_nTransformLevel = this.m_ContentInfo.evolve_type;
            return true;
        }


        public override bool IsSummon()
        {
            return true;
        }

        public int GetSummonSID()
        {
            return m_nSID;
        }

        public void SetSummonSID(int id)
        {
            this.m_nSID = id;
        }

        public int GetTransformLevel()
        {
            return this.m_ContentInfo.evolve_type;
        }
// Function       :   public int GetSP()
// Function       :   public int GetMaxSP()
// Function       :   public int StructSummon::AddSP(int)
// Function       :   public int StructSummon::SetSP(int)
// Function       :   public bool StructSummon::IsAlly(struct StructCreature *)

        public override void AddExp(long exp, long jp, bool bApplyStamina)
        {

            exp = (long)((double)exp * this.m_fEXPMod);
            jp = (long)((double)jp * this.m_fJPMod);

            if (this.m_master != null && this.m_master.m_bApplySummonEXPLimit)
                exp = Math.Min(exp, GameRule.GetSummonEXPLimit(this.GetLevel()));

            int maxLevel = 60;
            if(this.m_ContentInfo.evolve_type == 2)
                maxLevel = 115;
            else if (this.m_ContentInfo.evolve_type == 3)
                maxLevel = 170;

            if (GameContent.GetNeedSummonExp(maxLevel) - 1 <= this.m_nEXP)
                return;
            if (GameContent.GetNeedSummonExp(maxLevel - 1) < this.m_nEXP)
                exp = Math.Min(exp, (GameContent.GetNeedSummonExp(maxLevel) - 1) - this.m_nEXP);

            base.AddExp(exp, jp, true);
        }

        public override int GetSID()
        {
            return this.m_nSID;
        }

        public void SetName(string szName)
        {
            this.m_szName = szName;
        }

        public sbyte GetRidingInfo()
        {
            return m_ContentInfo.is_riding_only;
        }

        public int GetSummonCode()
        {
            return m_ContentInfo.uid;
        }

        public override string GetName()
        {
            return m_szName;
        }

        public override int GetCreatureGroup()
        {
            return m_ContentInfo.type;
        }
        public string GetSummonName()
        {
            return GameContent.GetString(m_ContentInfo.name_id);
        }
// Function       :   public int StructSummon::GetSummonNameId()
// Function       :   public int GetSummonType()
// Function       :   public int StructSummon::GetSummonElementalType()
// Function       :   public bool StructSummon::IsBattleMode()
// Function       :   public void SetBattleModeOn()
// Function       :   public void SetBattleModeOff()
// Function       :   public unsigned char GetSummonSlotIndex()
// Function       :   public void SetSummonSlotIndex(unsigned char)

        public override CreatureStat GetBaseStat()
        {
            return GameContent.GetStatInfo(this.m_ContentInfo.stat_id);
        }
// Function       :   public unsigned int StructSummon::GetHandle()
// Function       :   public unsigned char StructSummon::GetRace()
// Function       :   public float StructSummon::GetFCM()
// Function       :   public void SetMaster(struct StructPlayer *)
// Function       :   public struct StructPlayer * GetMaster()
// Function       :   public int GetAccountId()
// Function       :   public void SetAccountId(int)
// Function       :   public void SetParentCard(struct StructItem *)
// Function       :   public struct StructItem * GetParentCard()
// Function       :   public void SetSummonFlag(bool)
// Function       :   public bool GetSummonFlag()

        public bool DoEvolution()
        {
            int nTargetCode;
            int nCurrentCode;
            byte layer;
            int nCurrentLevel;
            long nCardUID;
            float prev_mp;
            int prev_hp;


            prev_hp = this.m_nHP;
            prev_mp = this.m_fMP;
            if (this.m_ContentInfo.evolve_type < 3 )
            {
                if (this.m_master.m_nRideIdx != 0 && this.m_master.GetRideObject().m_hHandle == this.m_hHandle)
                {
                    return false;
                }
                else
                {
                    nCurrentCode = this.m_ContentInfo.uid;
                    nTargetCode = this.m_ContentInfo.evolve_target;
                    nCurrentLevel = this.GetLevel();
                    this.SetSummonInfo((uint)nTargetCode);
                    this.CalculateStat();
                    this.m_master.Save(false);

                    PacketOut pak = new PacketOut(ClientOutPackets.SummonEvolution);
                    pak.WriteUInt32(this.m_item.m_hHandle);
                    pak.WriteUInt32(this.m_hHandle);
                    pak.FillString(this.m_szName, 19);
                    pak.WriteInt32(this.m_ContentInfo.uid);

                    if (this.bIsInWorld)
                    {
                        RappelzServer.Instance.Broadcast((uint)(this.mv.x / GameContent.g_nRegionSize),
                            (uint)(this.mv.y / GameContent.g_nRegionSize), this.m_layer, pak);
                    }
                    else
                    {
                        if (this.m_master != null)
                            this.m_master.Connection.SendTCP(pak);
                    }

                    if (GameContent.IsVisibleRegion((uint)(this.mv.x / GameContent.g_nRegionSize),
                            (uint)(this.mv.y / GameContent.g_nRegionSize),
                            (uint)(this.m_master.mv.x / GameContent.g_nRegionSize),
                            (uint)(this.m_master.mv.y / GameContent.g_nRegionSize)) == 0)
                        this.m_master.Connection.SendTCP(pak);

                    Messages.SendStatInfo(this.m_master, this);
                    Messages.SendHPMPMsg(this.m_master, this, this.m_nHP-prev_hp, (this.m_fMP-prev_mp),false);
                    Messages.SendLevelMsg(this.m_master, this);
                    Messages.SendExpMsg(this.m_master, this);
                    Messages.SendSPMsg(this.m_master, this);

                    nCardUID = 0;
                    if (this.m_item != null)
                    {
                        nCardUID = this.m_item.m_Instance.UID;
                        int i = 0;
                        for(i = 0; i < this.m_ContentInfo.evolve_type - 1; ++i)
                        {
                            this.m_item.m_Instance.Socket[i+1] = this.GetPrevJobLevel(i);
                        }
                        this.m_item.m_Instance.Socket[i + 1] = this.GetLevel();
                        if (this.m_master != null)
                            Messages.SendItemMessage(this.m_master, this.m_item);
                    }
                    ServerLog.Log((ushort)0xA2C,this.m_master.GetAccountID(),this.m_master.GetSID(),this.GetSID(),nCurrentCode,nTargetCode,nCurrentLevel,
                        this.m_nLevel,0,0,0,nCardUID,this.m_master.GetAccountName(),this.m_master.GetName(),this.GetName(),"");
                    return true;
                }
            }
            return false;

        }
// Function       :   public __int64 StructSummon::GetDeadEXPPenalty()

        public bool IsEXPLimitReached()
        {
            return GameContent.GetNeedSummonExp(170) - 1 <= this.m_nEXP;
        }


        public byte GetRidingMoveSpeed()
        {
            return 200;
        }
// Function       :   public int GetUnMountProbabilityOnDamage()
// Function       :   public int GetUnMountProbabilityOnCriticalDamage()
// Function       :   public int StructSummon::onDamage(struct StructCreature *, enum Elemental::Type, enum StructCreature::DamageType, int, bool)
// Function       :   public void StructSummon::AddToOwnedStateID(int)
// Function       :   public void RemoveFromOwnedStateID(int)
// Function       :   public bool StructSummon::IsUsingBow()
// Function       :   public bool StructSummon::IsUsingCrossBow()
        public override bool TranslateWearPosition(ref ItemBase.ItemWearType pos, Item item, ref List<int> ItemList)
        {
            return false;
        }

        public static void StageUpped(Item card, Summon ps)
        {
            if (card == null)
                return;

            Summon.CalculateInitialJP(card,ps);
            if(ps != null)
            {
                if (ps.m_nTransformLevel == 1)
                    ps.SetSummonInfo((uint)ps.m_nJob);
                else
                    ps.SetSummonInfo((uint)ps.m_nPrevJobId[0]);

                ps.m_nJobLevel = 1;
                ps.m_nLevel = 1;
                ps.CalculateStat();
                ps.m_master.Save(false);
            }


        }

// Function       :   public struct StructItem * StructSummon::GetWearedItem(enum ItemBase::ItemWearType)
// Function       :   public enum ItemBase::ItemWearType StructSummon::GetAbsoluteWearPos(enum ItemBase::ItemWearType &)
// Function       :   public float StructSummon::GetScale()
// Function       :   public float StructSummon::GetSize()
// Function       :   protected bool StructSummon::ProcDelete()
        protected override void applyState(State state)
        {

        }
// Function       :   protected void StructSummon::incParameter(int, int, bool)
// Function       :   protected void StructSummon::ampParameter(int, class c_fixed<10000>, bool)
        protected override void calcAttribute(CreatureAttributeServer attribute)
        {

        }
// Function       :   protected void StructSummon::onSPChange()
        protected override void onExpChange()
        {
            int level = 1;
            int lvl = 0;
            int oblv = 0;
            int jp = 0;
            switch(this.m_ContentInfo.evolve_type)
            {
                case 1:
                    lvl = 50;
                    oblv = 60;
                    break;

                case 2:
                    lvl = 100;
                    oblv = 115;
                    break;

                case 3:
                    lvl = 170;
                    oblv = 170;
                    break;
            }
            if (this.m_nMaxReachedLevel < this.m_nLevel )
                this.m_nMaxReachedLevel = this.m_nLevel;
            if (lvl > 1 )
            {
                do
                {
                    long need = GameContent.GetNeededSummonExp(level);
                    if (need == 0 || need > this.m_nEXP )
                        break;
                    ++level;
                    if (this.m_nMaxReachedLevel < level)
                    {
                        ++jp;
                        if (level > oblv)
                            ++jp;
                    }
                }
                while (level < oblv);
            }
            if (this.m_master != null)
                Messages.SendExpMsg(m_master, this);

            if (level != 0)
            {
                if ( level != this.m_nLevel )
                {
                    long uid = 0;
                    if (this.m_item != null )
                        uid = this.m_item.m_Instance.UID;
                    int ljp = 0;
                    if ( level <= this.m_nLevel )
                        ljp = 0;
                    else
                        ljp = jp;
                    ServerLog.Log(2601, m_master.GetAccountID(), m_master.GetSID(),this.GetSID(), this.m_nLevel, level,
                        this.GetPrevJobLevel(0),this.GetPrevJobLevel(1),this.GetJobId(), this.m_nJobPoint, ljp,uid,
                        m_master.GetAccountName(),m_master.GetName(),this.GetName(),this.GetSummonName());

                    int levelchange = level - this.m_nLevel;
                    this.m_nJobLevel = level;
                    this.m_nLevel = level;
                    if (levelchange <= 0)
                    {
                        this.CalculateStat();
                    }
                    else
                    {
                        int old_hp = this.m_nHP;
                        float old_mp = this.m_fMP;
                        this.m_nJobPoint += jp;
                        if (this.m_nMaxReachedLevel < level )
                            this.m_nMaxReachedLevel = level;
                        this.CalculateStat();

                        if (this.m_nHP != 0)
                        {
                            this.m_nHP = this.m_nMaxHP;
                            this.m_fMP = this.m_nMaxMP;
                        }
                        if (this.bIsInWorld )
                        {
                            Messages.BroadcastHPMPMsg(this, this.m_nHP - old_hp, (this.m_fMP - old_mp), false);
                        }
                        else
                        {
                            if (this.m_master != null)
                                Messages.SendHPMPMsg(this.m_master, this, this.m_nHP - old_hp, (this.m_fMP - old_mp), false);
                        }
                        if (this.m_master != null)
                        {
                            Messages.SendPropertyMessage(this.m_master, this.m_hHandle, "jp", this.m_nJobPoint);
                        }
                    }

                    this.DBQuery(new DB_UpdateSummon(this, false));
                    if (this.m_item != null && this.m_master != null)
                        Messages.SendItemMessage(this.m_master, this.m_item);

                    if (this.bIsInWorld )
                        Messages.BroadcastLevelMsg(this);

                    if (this.m_master != null)
                        Messages.SendLevelMsg(this.m_master, this);
                }
            }

        }
// Function       :   protected void StructSummon::onEnergyChange()
        protected override void onBeforeCalculateStat()
        {

        }

        protected override void applyJobLevelBonus()
        {

        }

        protected override void applyStatByState()
        {

        }

        protected override void onApplyStat()
        {

        }

// Function       :   protected void StructSummon::applyPassiveSkillEffect(struct StructSkill *)
// Function       :   protected void StructSummon::applyPassiveSkillEffect()
        protected override void applyPassiveSkillAmplifyEffect()
        {

        }
// Function       :   protected void StructSummon::onItemWearEffect(struct StructItem *, bool, int, class c_fixed<10000>, class c_fixed<10000>, float)
        protected override void onAfterApplyStat()
        {

        }

        protected override void onCompleteCalculateStat()
        {

        }

        protected override void onModifyStatAndAttribute()
        {

        }
// Function       :   protected void StructSummon::onCantAttack(unsigned int, unsigned long)
// Function       :   protected void StructSummon::onDead(struct StructCreature *, bool)
// Function       :   protected void StructSummon::onRegisterSkill(int, int, int, int)
// Function       :   protected unsigned short StructSummon::putonItem(enum ItemBase::ItemWearType, struct StructItem *)
// Function       :   protected unsigned short StructSummon::putoffItem(enum ItemBase::ItemWearType)
// Function       :   protected int StructSummon::getJPAfterSkillReset()
// Function       :   protected void StructSummon::onAfterResetSkill()
// Function       :   protected void StructSummon::onAfterRemoveState(struct StructState &)
// Function       :   protected void StructSummon::onUpdateState(struct StructState &, bool)

        public void onChangeProperty(string strKey, string data)
        {
            long longVal;

            switch(strKey)
            {
                case "lv":
                case "level":
                    this.m_nLevel = 0;
                    longVal = Marshal.ToInt64(data,0);
                    if(longVal <= 1)
                        longVal = 0;
                    else
                        longVal = GameContent.GetNeededSummonExp((int)(longVal-1));
                    this.SetEXP(longVal);
                    break;

                case "exp":
                    this.onExpChange();
                    break;

                case "hp":
                    longVal = Marshal.ToInt64(data,0);
                    Messages.BroadcastHPMPMsg(this, (int)longVal, 0, false);
                    break;

                default:
                    Messages.SendPropertyMessage(this.m_master, this.m_hHandle, strKey, data);
                    break;
            }

        }
// Function       :   protected bool StructSummon::IsAttackable()
// Function       :   protected const char * StructSummon::getClassName()

        public override void onProcess(int nThreadIdx)
        {
            RLock rl;
            AutoLock al;

            uint ct = Globals.GetArTime();
            if (this.bIsInWorld )
            {
                if (this.m_nHP == 0)
                {
                    rl = RappelzServer.Instance._LockObjectWithVisibleRange(this);
                    al = new AutoLock(rl.handle);
                    if (this.m_nDeadTime + 6000 < ct)
                    {
                        if (this.m_bIsEnable)
                        {
                            RappelzServer.Instance.SetObjectPriority(this, Priority.Idle);
                            this.m_master.UnSummon(this);
                        }
                    }
                    goto LABEL_7;
                }
                if (this.mv.bIsMoving && this.bIsInWorld )
                {
                    this.processWalk(ct);
                    this.m_nLastProcessTime = ct;
                    return;
                }
                if (this.m_hEnemy != 0 || this.IsUsingSkill())
                {
                    this.onAttackAndSkillProcess();
                    this.m_nLastProcessTime = ct;
                    return;
                }

                rl = RappelzServer.Instance._LockObjectWithVisibleRange(this);
                al = new AutoLock(rl.handle);

                if (this.bIsInWorld)
                {
                    if ((this.m_StatusFlag & StatusFlags.MovePending) != 0)
                    {
                        this.processPendingMove();
                    }
                    else
                    {
                        if (this.m_nLastProcessTime != 0)
                        {
                            if (this.m_nLastProcessTime + 500 < ct)
                            {
                                RappelzServer.Instance.SetObjectPriority(this, Priority.Idle);
                                this.m_nLastProcessTime = 0;
                            }
                            goto LABEL_14;
                        }
                    }
                    this.m_nLastProcessTime = ct;
                }
        LABEL_14:
                ;
//                v9 = &thisa;
            LABEL_7:
                ;
//                ArcadiaAutoLock::_ArcadiaAutoLock(v9);
            }
        }

        protected void processWalk(uint t)
        {
            ArMoveVector tmp_mv;// = new ArMoveVector();//         = ArMoveVector ptr -84h
// .text:0048FEF4 _lock           = ArcadiaAutoLock ptr -30h
// .text:0048FEF4 __lock          = ArcadiaLock ptr -18h
// .text:0048FEF4 ry              = dword ptr -14h
// .text:0048FEF4 t               = dword ptr  8
// 
// Data           :   ebp Relative, [00000008], Param, Type: unsigned long, t
// Data           :   ebp Relative, [FFFFFF7C], Local, Type: struct ArMoveVector, tmp_mv
// Data           :   ebp Relative, [FFFFFFD0], Local, Type: struct ArcadiaAutoLock, _lock
// Data           :   ebp Relative, [FFFFFFEC], Local, Type: unsigned int, ry
// Data           :   ebp Relative, [FFFFFFE8], Local, Type: struct ArcadiaLock, __lock
// Data           :   ebp Relative, [FFFFFFBC], Local, Type: struct ArcadiaAutoLock, _lock
            RLock rl = null;
            AutoLock al = null;

            Summon ro = this.m_master.GetRideObject();
            if (ro == null || ro.m_hHandle != this.m_hHandle)
            {
                rl = RappelzServer.Instance._LockObjectWithVisibleRange(this);
                al = new AutoLock(rl.handle);
                tmp_mv = new ArMoveVector(this.mv);
//                ArcadiaAutoLock::_ArcadiaAutoLock((v2 - 48));
                tmp_mv.Step(t);

                if ((tmp_mv.x / GameContent.g_nRegionSize) != (this.mv.x / GameContent.g_nRegionSize)
                  || (tmp_mv.y / GameContent.g_nRegionSize) != (this.mv.y / GameContent.g_nRegionSize)
                  || !tmp_mv.bIsMoving)
                {
//                     v8 = (v3->baseclass_0.baseclass_0.baseclass_0.mv.baseclass_0.x / v6);
//                     v9 = (v3->baseclass_0.baseclass_0.baseclass_0.mv.baseclass_0.y / v6);
//                     v10 = *(v2 - 128) / v6;
//                     *(v2 - 20) = v9;
//                     v11 = *(v2 - 24);
//                     v12 = *(v2 - 20);
//                     v13 = ArcadiaServer::Instance();
//                     ArcadiaServer::_LockArea(
//                         v13,
//                         (v2 - 24),
//                         v8,
//                         v12,
//                         v11,
//                         v10,
//                         "D:\\alienbrainWork\\Source Code\\@Rappelz\\Server\\GameServer_For_Update\\090721_GameServer\\Game\\NPCProc\\SummonAI.cpp",
//                         123);
//                     while ( 1 )
//                     {
//                         *(v2 - 16) = g_nRegionSize;
//                         if ( v8 == (v3->baseclass_0.baseclass_0.baseclass_0.mv.baseclass_0.x / *(v2 - 16)) )
//                         {
//                             if ( *(v2 - 20) == (v3->baseclass_0.baseclass_0.baseclass_0.mv.baseclass_0.y / *(v2 - 16)) )
//                                 break;
//                         }
//                         v14 = ArcadiaServer::Instance();
//                         ArcadiaServer::UnLock(v14, (v2 - 24));
//                         *(v2 - 16) = g_nRegionSize;
//                         v15 = *(v2 - 16);
//                         v8 = (v3->baseclass_0.baseclass_0.baseclass_0.mv.baseclass_0.x / *(v2 - 16));
//                         v16 = *(v2 - 128);
//                         *(v2 - 20) = (v3->baseclass_0.baseclass_0.baseclass_0.mv.baseclass_0.y / v15);
//                         v17 = (v16 / v15);
//                         v18 = *(v2 - 132) / v15;
//                         *(v2 - 16) = v17;
//                         v19 = *(v2 - 16);
//                         v20 = *(v2 - 20);
//                         v21 = ArcadiaServer::Instance();
//                         *(v2 - 24) = ArcadiaServer::_LockArea(
//                                          v21,
//                                          (v2 - 28),
//                                          v8,
//                                          v20,
//                                          v18,
//                                          v19,
//                                          "D:\\alienbrainWork\\Source Code\\@Rappelz\\Server\\GameServer_For_Update\\090721_GameServer\\Game\\NPCProc\\SummonAI.cpp",
//                                          133)->handle;
//                     }
//                     ArcadiaAutoLock::ArcadiaAutoLock(
//                         (v2 - 68),
//                         (v2 - 24),
//                         "D:\\alienbrainWork\\Source Code\\@Rappelz\\Server\\GameServer_For_Update\\090721_GameServer\\Game\\NPCProc\\SummonAI.cpp",
//                         136);
//                     v22 = v3->baseclass_0.baseclass_0.baseclass_0.mv.bIsMoving == 0;

                    if (this.mv.bIsMoving && this.bIsInWorld)
                    {
                        RappelzServer.Instance.onRegionChange(this, t - this.lastStepTime, !tmp_mv.bIsMoving);
                    }
//                    ArcadiaAutoLock::_ArcadiaAutoLock((v2 - 68));
                }
            }

        }

// Function       :   public void StructSummon(const struct StructSummon &)

        protected Summon(uint handle, uint idx)
        {
            this.m_hHandle = MemoryPool.AllocSummonId(this);
            this.m_nAccountId = 0;
            this.m_nLastProcessTime = 0;
            this.m_nArObjectType = 1;
            this.m_nTransformLevel = 0;
            this.SetSummonInfo(idx);
            this.m_fMaxSPAmplifier = 0.0f;
            this.m_fSPRegenAddAmplifier = 0.0f;
            this.m_nMaxSP = 1000;
            this.m_nSP = 1000;
            this.m_nStatus = 0;
            this.m_bIsSummoned = false;
            this.m_bIsRidable = 1;
            this.m_master = null;
            this.m_item = null;
            this.m_nSID = 0;
            this.m_nMaxReachedLevel = 1;
            this.m_nLevel = 1;
            this.m_nJobLevel = 1;
            this.m_cSlotIndex = 0;
            this.m_nMaxItemWear = 2;
            this.m_szName = "";
            this.m_nHP = this.m_nMaxHP;
            this.m_fMP = this.m_nMaxMP;
            this.m_nMaxReachedLevel = 1;
            this.m_nJobPoint = 1;
            this.m_fCM = 0.0f;
            this.m_fEXPMod = 1.0f;
            this.m_fJPMod = 1.0f;
            if (this.m_ContentInfo.is_riding_only == 1)
                this.SetSkill(-4, 11001, 1, 0);

            this.m_bIsBattleMode = false;
            this.m_nLastCantAttackTime = 0;
            this.m_nSPRegenAdd = 0;
            this.mv.face = Globals.GetRandomInt32() / 100;
//            XSEH::IncreaseAllocCount("StructSummon", 1);
        }

// Function       :   protected void StructSummon::StructSummon(const char *)
// Function       :   protected void StructSummon::~StructSummon()
        public int m_nSP;                                                   // 0xFE4
        public int m_nMaxSP;                                                // 0xFE8
        public float m_fMaxSPAmplifier;                                     // 0xFEC
        public short m_nSPAdd;                                              // 0xFF0
        public short m_nSPRegenAdd;                                         // 0xFF2
        public float m_fSPRegenAddAmplifier;                                // 0xFF4
        public float m_fBaseAttackPointRatio;                               // 0xFF8
        public float m_fBaseMagicPointRatio;                                // 0xFFC
        public float m_fBaseDefenceRatio;                                   // 0x1000
        public float m_fBaseMagicDefenceRatio;                              // 0x1004
        public float m_fCM;                                                 // 0x1008
        public int m_bIsRidable;                                            // 0x100C
        public float m_fRideSpeedMod;                                       // 0x1010
        public int m_nUnMountProbabilityOnDamage;                           // 0x1014
        public int m_nUnMountProbabilityOnCriticalDamage;                   // 0x1018
        public float m_fEXPMod;                                             // 0x101C
        public float m_fJPMod;                                              // 0x1020
        public float m_fSoulConnectionRatio;                                // 0x1024
        public int m_nAccountId;                                            // 0x1028
        public Player m_master;                                             // 0x102C
        public Item m_item;                                                 // 0x1030
        public SummonBase m_ContentInfo = new SummonBase();                 // 0x1034
        public int m_nMaxItemWear;                                          // 0x1038
        public bool m_bIsSummoned;                                          // 0x103C
        public string m_szName;                                             // 0x103D
//        public uint m_hHandle;                                            // 0x107C
        public int m_nSID;                                                  // 0x1080
        public List<int> m_vStateIDList = new List<int>();                  // 0x1084 
        public int m_nTransformLevel;                                       // 0x1094
        public int m_nStatus;                                               // 0x1098
        public byte m_cSlotIndex;                                           // 0x109C
        public uint m_nLastCantAttackTime;                                  // 0x10A0
        public uint m_nLastProcessTime;                                     // 0x10A4
        public bool m_bIsBattleMode;                                        // 0x10A8
        public List<Skill> m_vMasterAmplifyPassiveSkillList = new List<Skill>();    // 0x10AC
// Data           :   this+0x10BC, Member, Type: class XCriticalSection, m_bQueryLock
    }
}
